/* Gallery Grid using CSS Variables from settings */
.dgm-gallery-grid {
    display: grid;
    gap: var(--dgm-gap, 20px);
    grid-template-columns: repeat(var(--dgm-cols-mobile, 1), 1fr); /* Mobile first */
}
@media (min-width: 768px) {
    .dgm-gallery-grid {
        grid-template-columns: repeat(var(--dgm-cols-tablet, 2), 1fr);
    }
}
@media (min-width: 1024px) {
    .dgm-gallery-grid {
        grid-template-columns: repeat(var(--dgm-cols-desktop, 3), 1fr);
    }
}

/* Gallery Item Card Styling */
.dgm-gallery-item {
    position: relative;
    overflow: hidden;
    background-color: #000;
    border-radius: var(--dgm-radius, 8px);
    border: var(--dgm-border-width, 0px) solid var(--dgm-border-color, #ddd);
    box-shadow: var(--dgm-shadow, 0 5px 15px rgba(0,0,0,0.1));
    aspect-ratio: 1 / 1;
}

.dgm-gallery-item a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.dgm-gallery-item img {
    width: 100%;
    height: 100%;
    /* The object-fit is now controlled by an inline style directly on the element */
    /* A fallback can be set here, but the inline style will always win */
    object-fit: cover; 
    transition: transform 0.4s ease, opacity 0.4s ease;
}

/* Hover Effect */
.dgm-gallery-item:hover img {
    transform: scale(1.1);
    opacity: 0.5;
}

/* Overlay with Icon */
.dgm-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.4s ease;
    padding: 15px;
    box-sizing: border-box;
}

.dgm-gallery-item:hover .dgm-overlay {
    opacity: 1;
}

.dgm-icon {
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>');
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.3s ease;
}
.dgm-gallery-item:hover .dgm-icon {
    transform: scale(1.1);
}

/* Title and Image Count */
.dgm-item-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 20px 10px 10px;
    text-align: center;
    color: #fff;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    transition: all 0.3s ease;
}
.dgm-item-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
}
.dgm-item-count {
    font-size: 12px;
    opacity: 0.8;
}

/* Auto-crop thumbnail images to fill container without black bars */
.thumbnail img,
.gallery img,
img.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
